import request from '@/utils/request'

export function sendMsg(data) {
  return request({
    url: `/chat/sendMsg`,
    method: 'post',
    data
  })
} 

export function recallMsgApi(data) {
  return request({
    url: `/chat/recallMsg`,
    method: 'post',
    data
  })
} 
export function getChatMsgListApi(params) {
  return request({
    url: `/chat/list`,
    method: 'get',
    params
  })
} 

export function getFriendsListApi(userId) {
  console.log(userId);
  return request({
    url: `/chat/friendsList/`+userId,
    method: 'get',
  })
}

export function getRoomsListApi(userId) {
  return request({
    url: `/chat/rooms/`+userId,
    method: 'get',
  })
}

export function getRoomWithUserApi(userId, friendId) {
  return request({
    url: `/chat/roomWithFriend/${userId}/${friendId}`,
    method: 'get',
  })
}

export function getFriendInfoApi(friendId) {
  return request({
    url: `/chat/friendInfo/${friendId}`,
    method: 'get',
  })
}

export function getLastMsg(roomId) {
  return request({
    url: `/chat/lastmsg/${roomId}`,
    method: 'get',
  })
}

export function updateUnreadCount(roomId,unreadCount,userId){
  return request({
    url: `/chat/updateUnreadCount/${roomId}/${unreadCount}/${userId}`,
    method: 'get',
  })
}